﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Mogre;

namespace ProjetSMA.View.Mogre
{
    class Map
    {
        private SceneManager mSceneMngr;
        private Root m_root;
        private SceneNode m_scene;
        private Viewport m_viewport;

        public Map(SceneManager smngr, Root r, Viewport par_viewport)
        {
            mSceneMngr = smngr;
            m_root = r;
            m_viewport = par_viewport;
        }

        public void CreateTerrain()
        {

            mSceneMngr.SetSkyBox(true, "Examples/EveningSkyBox", 2020, true);
          //  mSceneMngr.AmbientLight = new ColourValue(0.7f, 0.7f, 0.9f);

           // mSceneMngr.AmbientLight = new ColourValue(0.3f, 0.3f, 0.3f);

            mSceneMngr.AmbientLight = new ColourValue(0.25f, 0.25f, 0.55f);

           
          //  mSceneMngr.ShadowTechnique = ShadowTechnique.SHADOWTYPE_TEXTURE_MODULATIVE;

             mSceneMngr.ShadowTechnique = ShadowTechnique.SHADOWTYPE_STENCIL_ADDITIVE;
             mSceneMngr.ShadowColour = ColourValue.Black;
             mSceneMngr.ShadowFarDistance = 1000;




             m_scene = mSceneMngr.RootSceneNode.CreateChildSceneNode("sun");
             m_scene.Position = new Vector3(350, 300, 350);

            /* 
            
             Light spotLight = mSceneMngr.CreateLight("spotLight");
             spotLight.Type = Light.LightTypes.LT_SPOTLIGHT;
             spotLight.DiffuseColour = new ColourValue(1f, 1f, 1f);
             spotLight.SpecularColour = new ColourValue(1f, 1f, 1f);
             spotLight.Direction = new Vector3(0, -1, 0);
             spotLight.Position = m_scene.Position;

             spotLight.SetSpotlightRange(new Degree(60), new Degree(60));

            */
             Light directionalLight = mSceneMngr.CreateLight("directionalLight");
             directionalLight.Type = Light.LightTypes.LT_POINT;
             directionalLight.DiffuseColour = new ColourValue(0.8f, 0.8f, 1);
             directionalLight.SpecularColour = new ColourValue(1, 1, 1);
             //directionalLight.Visible = true;
             //directionalLight.Direction = new Vector3(0, -1, 1);
             directionalLight.Position = m_scene.Position;

            
             m_scene.AttachObject(directionalLight);
            

             BillboardSet loc_bill_set = mSceneMngr.CreateBillboardSet("sun");
             loc_bill_set.SetMaterialName("Examples/Flare");

             Billboard loc_bill = loc_bill_set.CreateBillboard(m_scene.Position);
             loc_bill.Colour = new ColourValue(0.9f, 0.9f, 1f);
             loc_bill_set.Visible = true;

             m_scene.AttachObject(loc_bill_set);

             ColourValue fadeColour = new ColourValue(0.1f, 0.1f, 0.1f);
             m_viewport.BackgroundColour = fadeColour;

             //mSceneMngr.SetFog(FogMode.FOG_EXP, fadeColour, 0.0003f);
        }
        

    }
}
